import 'package:xinxuan/vo/common_vo/common_address_item_vo.dart';
import 'package:xinxuan/vo/common_vo/common_pagination_vo.dart';

class StoreOrderListVo {

  List<StoreOrderItem>? data;
  StoreOrderMeta? meta;

  StoreOrderListVo({this.data, this.meta});

  StoreOrderListVo.fromJson(Map<String, dynamic> json) {
    if (json['data'] != null) {
      data = [];
      json['data'].forEach((v) {
        data!.add(new StoreOrderItem.fromJson(v));
      });
    }
    meta = json['meta'] != null ? new StoreOrderMeta.fromJson(json['meta']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    if (this.meta != null) {
      data['meta'] = this.meta!.toJson();
    }
    return data;
  }
}

class StoreOrderItem {
  int? id;
  int? type;
  String? orderSn;
  int? userId;
  int? status;
  String? statusStr;
  int? paymentType;
  int? payStatus;
  String? payAmount;
  String? totalAmount;
  String? createdAt;
  String? updatedAt;
  String? paidAt;
  String? deletedAt;
  int? pickType;
  String? voucherCode;
  List<StoreProductsItem>? products;
  CommonAddressItem? address;
  int? transferRemaining;
  int? isTransfer;

  StoreOrderItem(
      {this.id,
      this.type,
      this.orderSn,
      this.userId,
      this.status,
      this.statusStr,
      this.paymentType,
      this.payStatus,
      this.payAmount,
      this.totalAmount,
      this.createdAt,
      this.updatedAt,
      this.paidAt,
      this.deletedAt,
      this.products,
      this.address,
      this.pickType,
      this.voucherCode,
      this.transferRemaining,
      this.isTransfer});

  StoreOrderItem.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    type = json['type'];
    orderSn = json['order_sn'];
    userId = json['user_id'];
    status = json['status'];
    statusStr = json['status_str'];
    paymentType = json['payment_type'];
    payStatus = json['pay_status'];
    payAmount = json['pay_amount'];
    totalAmount = json['total_amount'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    paidAt = json['paid_at'];
    deletedAt = json['deleted_at'];
    pickType = json['pick_type'];
    voucherCode = json['voucher_code'];
    transferRemaining = json['transfer_remaining'];
    isTransfer = json['is_transfer'];
    if (json['products'] != null) {
      products = [];
      json['products'].forEach((v) {
        products!.add(new StoreProductsItem.fromJson(v));
      });
    }
    if (pickType == 1) {
      address = null;
    } else {
      address = json['address'] != null ? new CommonAddressItem.fromJson(json['address']) : null;
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['type'] = this.type;
    data['order_sn'] = this.orderSn;
    data['user_id'] = this.userId;
    data['status'] = this.status;
    data['status_str'] = this.statusStr;
    data['payment_type'] = this.paymentType;
    data['pay_status'] = this.payStatus;
    data['pay_amount'] = this.payAmount;
    data['total_amount'] = this.totalAmount;
    data['created_at'] = this.createdAt;
    data['updated_at'] = this.updatedAt;
    data['paid_at'] = this.paidAt;
    data['deleted_at'] = this.deletedAt;
    data['pick_type'] = this.pickType;
    data['voucher_code'] = this.voucherCode;
    data['transfer_remaining'] = this.transferRemaining;
    data['is_transfer'] = this.isTransfer;
    if (this.products != null) {
      data['products'] = this.products!.map((v) => v.toJson()).toList();
    }
    if (this.address != null) {
      data['address'] = this.address!.toJson();
    }
    return data;
  }
}

class StoreProductsItem {
  int? id;
  int? orderId;
  int? productId;
  String? title;
  String? image;
  String? price;
  int? quantity;
  int? skuId;
  String? specIds;
  String? specStr;

  StoreProductsItem(
      {this.id,
      this.orderId,
      this.productId,
      this.title,
      this.image,
      this.price,
      this.quantity,
      this.skuId,
      this.specIds,
      this.specStr});

  StoreProductsItem.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    orderId = json['order_id'];
    productId = json['product_id'];
    title = json['title'];
    image = json['image'];
    price = json['price'];
    quantity = json['quantity'];
    skuId = json['sku_id'];
    specIds = json['spec_ids'];
    specStr = json['spec_str'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['order_id'] = this.orderId;
    data['product_id'] = this.productId;
    data['title'] = this.title;
    data['image'] = this.image;
    data['price'] = this.price;
    data['quantity'] = this.quantity;
    data['sku_id'] = this.skuId;
    data['spec_ids'] = this.specIds;
    data['spec_str'] = this.specStr;
    return data;
  }
}

class StoreOrderMeta {
  List<Aggregate>? aggregate;
  CommonPagination? pagination;

  StoreOrderMeta({this.aggregate, this.pagination});

  StoreOrderMeta.fromJson(Map<String, dynamic> json) {
    if (json['aggregate'] != null) {
      aggregate = <Aggregate>[];
      json['aggregate'].forEach((v) {
        aggregate!.add(new Aggregate.fromJson(v));
      });
    }
    pagination = json['pagination'] != null
        ? new CommonPagination.fromJson(json['pagination'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.aggregate != null) {
      data['aggregate'] = this.aggregate!.map((v) => v.toJson()).toList();
    }
    if (this.pagination != null) {
      data['pagination'] = this.pagination!.toJson();
    }
    return data;
  }
}

class Aggregate {
  int? pickType;
  int? status;
  int? total;
  String? label;

  Aggregate({this.pickType, this.status, this.total, this.label});

  Aggregate.fromJson(Map<String, dynamic> json) {
    pickType = json['pick_type'];
    status = json['status'];
    total = json['total'];
    label = json['label'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['pick_type'] = this.pickType;
    data['status'] = this.status;
    data['total'] = this.total;
    data['label'] = this.label;
    return data;
  }
}

